<?php
require_once("scripts/constraint.php");
require_once("scripts/EKUser.php");

session_start();

function checkAdmin()
{
	if(!isset($_SESSION['userid']) || $_SESSION['userid']=="")
		return false;

	$thisUser = new EKUser($_SESSION['userid']);
	if(!$thisUser)
		return false;
	
	if($thisUser->getType() != 3)
		return false;
		
	return true;
}

if(checkAdmin())
{
	switch($_GET['action'])
	{
		case "disable":
			EKUser::updateDB($_GET['userid'], "enabled", 0);
			break;
		case "enable":
			
			EKUser::updateDB($_GET['userid'], "enabled", 1);
			break;
		case "committee":
			EKUser::updateDB($_GET['userid'], "type", 1);
			break;
		case "regular":
			EKUser::updateDB($_GET['userid'], "type", 0);
			break;
		default:
	}
	echo "<script language=javascript>window.history.back();</script>";
}else{
	echo "<script language=javascript>window.history.back();</script>";
}
?>